#!/bin/bash


app_home=/opt/gmall211025
jar=gmall-realtime-1.0-SNAPSHOT.jar
flink=/opt/module/flink-1.13.1/bin/flink

# 数组存储要运行的类名
apps=(
com.lcc.realtime.app.dwd.DwdLogApp
#com.atguigu.gmall.realtime.app.dwd.DwdDbpp
)

# 获取到所有正在运行的app的名字
runnings=`$flink list -r 2>/dev/null | awk '/RUNNING/{print \$(NF-1)}'`

# 遍历app数组
for app in ${apps[*]} ; do
    app_name=`echo $app | awk -F. '{print \$NF}'`

    if [[ "${runnings[@]}" =~ "$app_name" ]]; then
        echo "应用: $app_name 已经启动, 无序重复启动"
    else
         echo "启动应用: $app_name"
         $flink run -d -c $app $jar
    fi

done


